package com.kid.keep.service.impl;

import com.kid.keep.dao.app.AppRepository;
import com.kid.keep.dto.AppDTO;
import com.kid.keep.enums.DateStatusEnum;
import com.kid.keep.mapper.IAppCovertMapper;
import com.kid.keep.po.App;
import com.kid.keep.service.IAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: App
 * @Author: jianjun.cheng
 * @Create: 2020-02-04 16:39
 * @Since 1.0.0
 **/
@Service
public class AppServiceImpl implements IAppService {

    private AppRepository appRepository;

    private IAppCovertMapper appCovertMapper;

    @Autowired
    public void setAppCovertMapper(IAppCovertMapper appCovertMapper) {
        this.appCovertMapper = appCovertMapper;
    }

    @Autowired
    public AppServiceImpl(AppRepository appRepository) {
        this.appRepository = appRepository;
    }


    @Override
    public AppDTO findByWxAppId(String appId) {
        App app = appRepository.findByWxAppIdAndDataStatus(appId, DateStatusEnum.VALID.getValue());
        return appCovertMapper.toDTO(app);
    }
}
